/**
 * 
 */
package com.ttl.erp.order.yd;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.LookupDispatchAction;

import com.ttl.bc.ap.invoice.bo.BCAPInvoiceBO;
import com.ttl.bc.ap.purchaseorder.chemical.ChemicalBO;

/**
 *  @author :  Surasak Lekmart
 *  Created :  26 Jun 2012 11:24:42 
 *  Project :  ittl
 */
public class TTL_ORDER_YD_Action extends LookupDispatchAction {
 
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	protected Map getKeyMethodMap() {
		Map map = new HashMap();
		map.put("orderydForm.add", "add");
		map.put("orderydForm.update", "update");
		map.put("orderydForm.delete", "delete");
		map.put("orderydForm.blank", "blank");
		//map.put("orderydForm.cal", "cal");
		//map.put("orderydForm.createpo", "createpo");
		//map.put("orderydForm.ponew", "ponew");
		//map.put("orderydForm.chemicalHistory", "chemicalHistory");
		map.put("orderydForm.showFind", "showFind");
		map.put("orderydForm.view", "view");
		
		return map;
	}
	
	public ActionForward add(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) 
			throws Exception {
		
		if (new TTL_ORDER_YD_BO().add(form, request, response)==true) {

			return mapping.findForward("success_add");
		}else {
			//ทำ map กับการ fail_add
			return mapping.findForward("fail_add");
		}		
	}
	
	public ActionForward blank(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) 
			throws Exception {
		return mapping.findForward("success_blank");
	}
	public ActionForward delete(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) 
			throws Exception {
		
		if (new TTL_ORDER_YD_BO().delete(form, request, response)==true) {							
			return mapping.findForward("success_delete");
		}else {
			return mapping.findForward("fail_delete");
		}		
	}	
	public ActionForward showFind(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) 
			throws Exception {
				
		new TTL_ORDER_YD_BO().showFind(request);
		return mapping.findForward("success_showFind");
		
	}
	
	public ActionForward update(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) 
			throws Exception {
		
		if (new TTL_ORDER_YD_BO().update(form, request, response)==true) {							
			return mapping.findForward("success_update");
		}else {
			return mapping.findForward("fail_update");
		}		
	}
	
	public ActionForward view(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) 
			throws Exception {
		
		if (new TTL_ORDER_YD_BO().view(form, request, response)==true) {							
			return mapping.findForward("success_view");
		}else {
			return mapping.findForward("fail_view");
		}		
	}	
}
